package com.mit.service.design.dao.impl;

import com.mit.common.design.dto.FabricDTO;
import com.mit.common.exception.NoRecordUpdateException;
import com.mit.service.core.dao.AbstractDAO;
import com.mit.service.design.dao.IFabricDAO;

public class FabricDAOImpl extends AbstractDAO implements IFabricDAO {

	@Override
	public FabricDTO createSimpleFabric(FabricDTO to) {
		int id = (Integer) getSqlMapClientTemplate().insert("insertFabric", to);
		to.setId(id);
		return to;
	}

	@Override
	public FabricDTO updateSimpleFabric(FabricDTO to)
			throws NoRecordUpdateException {
		int i = getSqlMapClientTemplate().update("updateFabric", to);
		if(i < 1)
			throw new NoRecordUpdateException();
		return to;
	}

	@Override
	public void deleteFabric(Integer id) {
		getSqlMapClientTemplate().delete("deleteFabric", id);
		
	}

	@Override
	public FabricDTO updateFabricEstimation(FabricDTO to)
			throws NoRecordUpdateException {
		int i = getSqlMapClientTemplate().update("updateFabicEstimation", to);
		if(i < 1)
			throw new NoRecordUpdateException();
		return to;
	}
	

}
